package com.yinhe.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.yinhe.common.annotation.Log;
import com.yinhe.common.core.controller.BaseController;
import com.yinhe.common.core.domain.AjaxResult;
import com.yinhe.common.enums.BusinessType;
import com.yinhe.system.domain.YhActivatePaticipant;
import com.yinhe.system.service.IYhActivatePaticipantService;
import com.yinhe.common.utils.poi.ExcelUtil;
import com.yinhe.common.core.page.TableDataInfo;

/**
 * 活动参与人信息Controller
 * 
 * @author yinhe
 * @date 2022-09-06
 */
@RestController
@RequestMapping("/system/paticipant")
public class YhActivatePaticipantController extends BaseController
{
    @Autowired
    private IYhActivatePaticipantService yhActivatePaticipantService;

    /**
     * 查询活动参与人信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:paticipant:list')")
    @GetMapping("/list")
    public TableDataInfo list(YhActivatePaticipant yhActivatePaticipant)
    {
        startPage();
        List<YhActivatePaticipant> list = yhActivatePaticipantService.selectYhActivatePaticipantList(yhActivatePaticipant);
        return getDataTable(list);
    }

    /**
     * 导出活动参与人信息列表
     */
    @PreAuthorize("@ss.hasPermi('system:paticipant:export')")
    @Log(title = "活动参与人信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, YhActivatePaticipant yhActivatePaticipant)
    {
        List<YhActivatePaticipant> list = yhActivatePaticipantService.selectYhActivatePaticipantList(yhActivatePaticipant);
        ExcelUtil<YhActivatePaticipant> util = new ExcelUtil<YhActivatePaticipant>(YhActivatePaticipant.class);
        util.exportExcel(response, list, "活动参与人信息数据");
    }

    /**
     * 获取活动参与人信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:paticipant:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(yhActivatePaticipantService.selectYhActivatePaticipantById(id));
    }

    /**
     * 新增活动参与人信息
     */
    @PreAuthorize("@ss.hasPermi('system:paticipant:add')")
    @Log(title = "活动参与人信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody YhActivatePaticipant yhActivatePaticipant)
    {
        return toAjax(yhActivatePaticipantService.insertYhActivatePaticipant(yhActivatePaticipant));
    }

    /**
     * 修改活动参与人信息
     */
    @PreAuthorize("@ss.hasPermi('system:paticipant:edit')")
    @Log(title = "活动参与人信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody YhActivatePaticipant yhActivatePaticipant)
    {
        return toAjax(yhActivatePaticipantService.updateYhActivatePaticipant(yhActivatePaticipant));
    }

    /**
     * 删除活动参与人信息
     */
    @PreAuthorize("@ss.hasPermi('system:paticipant:remove')")
    @Log(title = "活动参与人信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(yhActivatePaticipantService.deleteYhActivatePaticipantByIds(ids));
    }
}
